//
//  XCInTheSingerTableViewCell.m
//  SoundOfNature
//
//  Created by 梁新昌 on 16/3/16.
//  Copyright © 2016年 梁新昌. All rights reserved.
//

#import "XCInTheSingerTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation XCInTheSingerTableViewCell


- (void)dealloc {
    [_moreButton release];
    [_singer_name release];
    [_numberLable release];
    [_pic_urlImageView release];
    [_inTheSingerModel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.pic_urlImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        
        
        
        
        self.numberLable = [[XCBaseLable alloc] initWithFrame:CGRectZero];
        self.singer_name = [[XCBaseLable alloc] initWithFrame:CGRectZero];
        self.moreButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.moreButton setImage:[[UIImage imageNamed:@"Image-more"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        
        [self.contentView addSubview:self.pic_urlImageView];
        [self.contentView addSubview:self.singer_name];
        [self.contentView addSubview:self.moreButton];
        [self.contentView addSubview:self.numberLable];
        
        
        [self.pic_urlImageView release];
        [self.numberLable release];
        [self.singer_name release];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.numberLable.frame = CGRectMake(5, self.bounds.size.height / 2 - 10, 20, 21);
    self.numberLable.font = [UIFont systemFontOfSize:13];
    
    self.pic_urlImageView.frame = CGRectMake(30, 10, self.bounds.size.width / 5 - 20, self.bounds.size.width / 5 - 20);
    
    [self.pic_urlImageView.layer setCornerRadius:(self.bounds.size.width / 5 - 20) / 2];
    self.pic_urlImageView.layer.masksToBounds = YES;
    //    然后再给图层添加一个有色的边框
    self.pic_urlImageView.layer.borderWidth = 1;
    self.pic_urlImageView.layer.borderColor = [[UIColor colorWithRed:0.400 green:1.000 blue:1.000 alpha:1.000] CGColor];
    
    self.singer_name.frame = CGRectMake(self.pic_urlImageView.frame.size.width + self.pic_urlImageView.frame.origin.x + 20, self.bounds.size.height / 2 - 10, self.bounds.size.width / 4, 21);
    self.singer_name.font = [UIFont systemFontOfSize: 15];
    self.singer_name.textColor = [UIColor colorWithWhite:0.800 alpha:0.8];
    self.moreButton.frame = CGRectMake(self.bounds.size.width - 70, self.bounds.size.height / 2 - 15, 30, 30);
    
}
- (void)setInTheSingerModel:(XCInTheSingerModel *)inTheSingerModel {
    if (_inTheSingerModel != inTheSingerModel) {
        [_inTheSingerModel release];
        _inTheSingerModel = [inTheSingerModel retain];
    }
    
    self.singer_name.text = inTheSingerModel.singer_name;
    [self.pic_urlImageView sd_setImageWithURL:[NSURL URLWithString:inTheSingerModel.pic_url]placeholderImage:[UIImage imageNamed:@"Image-p"]];
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
